﻿<phone:PhoneApplicationPage x:Class="CDFWPUG.Views.pageGroupApps"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                            xmlns:converters="clr-namespace:CDFWPUG.Converters"
                            mc:Ignorable="d"
                            d:DesignWidth="480"
                            d:DesignHeight="696"
                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}"
                            SupportedOrientations="Portrait"
                            Orientation="Portrait"
                            shell:SystemTray.IsVisible="True"
                            DataContext="{Binding PageGroupApps, Source={StaticResource Locator}}">

    <phone:PhoneApplicationPage.Resources>
        <converters:GroupToBrushValueConverter x:Key="groupBrush"/>
    </phone:PhoneApplicationPage.Resources>
    
    <StackPanel  x:Name="LayoutRoot"
		Background="{StaticResource MyPhoneBackgroundBrush}" DataContext="{Binding Mode=OneWay}">

		<TextBlock x:Name="tbGroupAppsMessage" Text="{Binding GroupAppsMessage}" 
			Foreground="{StaticResource MyPhoneAccentBrush}" 
			TextWrapping="Wrap" Style="{StaticResource MyPhoneTextAccentStyle}" Margin="12,0,44,0" />
		<toolkit:PerformanceProgressBar 
			x:Name="pbGroupApps" 
			Visibility="{Binding GroupAppsLoading, Converter={StaticResource MyBooleanToVisibilityConverter}}"
			IsIndeterminate="True" Foreground="{StaticResource MyPhoneAccentBrush}" Margin="0,0,32,0" />



		<toolkit:LongListSelector x:Name="listApps" Background="Transparent"
			Margin="10,10,-10,10"
			GroupViewOpened="listApps_GroupViewOpened"
			GroupViewClosing="listApps_GroupViewClosing"
			ItemsSource="{Binding GroupedApps}" Height="750" 
			ItemTemplate="{StaticResource AppListItem}" Width="480" 
			ShowListHeader="False" ShowListFooter="False">
			<toolkit:LongListSelector.GroupItemsPanel>
				<ItemsPanelTemplate>
					<toolkit:WrapPanel Orientation="Horizontal"/>
				</ItemsPanelTemplate>
			</toolkit:LongListSelector.GroupItemsPanel>
			<toolkit:LongListSelector.GroupItemTemplate>
				<DataTemplate>
					<Border Background="{Binding Converter={StaticResource groupBrush}}" 
						Width="99" Height="99" Margin="6" IsHitTestVisible="{Binding HasItems}">
						<TextBlock Text="{Binding Title}" 
							FontFamily="{StaticResource PhoneFontFamilySemiBold}"
							Style="{StaticResource MyPhoneTextLargeStyle}"
							FontSize="36"
							Margin="0,0,0,0"
							Foreground="{StaticResource MyPhoneContrastForegroundBrush}"                                        
							VerticalAlignment="Bottom"/>
					</Border>
				</DataTemplate>
			</toolkit:LongListSelector.GroupItemTemplate>
			<toolkit:LongListSelector.GroupHeaderTemplate>
				<DataTemplate>
					<Border Background="Transparent">
						<Border BorderThickness="1" BorderBrush="{StaticResource MyPhoneAccentBrush}" 
							Width="63" Height="63" HorizontalAlignment="Left">
							<TextBlock Text="{Binding Title}" 
								Foreground="{StaticResource MyPhoneAccentBrush}" 
								Style="{StaticResource PhoneTextExtraLargeStyle}"
								VerticalAlignment="Bottom"/>
						</Border>
					</Border>
				</DataTemplate>
			</toolkit:LongListSelector.GroupHeaderTemplate>

		</toolkit:LongListSelector>



	</StackPanel>


</phone:PhoneApplicationPage>